package com.mzj.saas.electronicVisa;

import java.util.List;


import com.haixiaoke.saas.repository.core.AjaxResult;
import com.haixiaoke.saas.repository.core.BaseController;
import com.haixiaoke.saas.repository.core.page.TableDataInfo;
import com.haixiaoke.saas.repository.electronicVisa.pojo.ContractRecord;
import com.haixiaoke.saas.repository.electronicVisa.service.IContractRecordService;
import com.mzj.saas.annotation.CheckAuth;
import com.mzj.saas.util.LoginUserUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 企业合同消耗记录Controller
 *
 * @author qixi
 * @date 2024-03-08
 */
@RestController
@RequestMapping("/electronicVisa/record")
public class ContractRecordController extends BaseController {
    @Autowired
    private IContractRecordService contractRecordService;
    @Autowired
    private LoginUserUtil loginUserUtil;

    /**
     * 查询企业合同消耗记录列表
     */
    @GetMapping("/list")
    @CheckAuth
    public TableDataInfo list(ContractRecord contractRecord) {
        startPage();
        contractRecord.setOrgId(loginUserUtil.getOrgId());
        List<ContractRecord> list = contractRecordService.selectContractRecordList(contractRecord);
        return getDataTable(list);
    }
    //
    // /**
    //  * 导出企业合同消耗记录列表
    //  */
    // @PreAuthorize("@ss.hasPermi('repository:record:export')")
    // @Log(title = "企业合同消耗记录", businessType = BusinessType.EXPORT)
    // @PostMapping("/export")
    // public void export(HttpServletResponse response, ContractRecord contractRecord) {
    //     List<ContractRecord> list = contractRecordService.selectContractRecordList(contractRecord);
    //     ExcelUtil<ContractRecord> util = new ExcelUtil<ContractRecord>(ContractRecord.class);
    //     util.exportExcel(response, list, "企业合同消耗记录数据");
    // }

    /**
     * 获取企业合同消耗记录详细信息
     */
    @GetMapping(value = "/{recordId}")
    public AjaxResult getInfo(@PathVariable("recordId") Long recordId) {
        return success(contractRecordService.selectContractRecordByRecordId(recordId));
    }

    /**
     * 新增企业合同消耗记录
     */
    @PostMapping
    public AjaxResult add(@RequestBody ContractRecord contractRecord) {
        return toAjax(contractRecordService.insertContractRecord(contractRecord));
    }

    /**
     * 修改企业合同消耗记录
     */
    @PutMapping
    public AjaxResult edit(@RequestBody ContractRecord contractRecord) {
        return toAjax(contractRecordService.updateContractRecord(contractRecord));
    }

    /**
     * 删除企业合同消耗记录
     */
	@DeleteMapping("/{recordIds}")
    public AjaxResult remove(@PathVariable Long[] recordIds) {
        return toAjax(contractRecordService.deleteContractRecordByRecordIds(recordIds));
    }
}
